package view.controller;

import javafx.fxml.FXMLLoader;
import javafx.fxml.JavaFXBuilderFactory;
import javafx.scene.Parent;

import java.io.IOException;
import java.net.URL;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: SmartBoy
 * @Date: 2021/10/27/22:04
 * @Description:
 */
public class ControllerTool {
    private FXMLLoader fxmlLoader;

    public ControllerTool(String url){
        URL resource = getClass().getClassLoader().getResource(url);
        fxmlLoader = new FXMLLoader(resource);
        fxmlLoader.setLocation(resource);
        fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
    }

    public Parent getParent() throws IOException {
        return fxmlLoader.load();
    }

    public Object getController(){
        return fxmlLoader.getController();
    }
}
